Completed
Push — master ( fa4c5d...fa4c5d )
by Maxence
05:16 queued 02:40
created

actions.saveSettings   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
/*
2
 * Circles - Bring cloud-users closer together.
3
 *
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later. See the COPYING file.
6
 *
7
 * @author Maxence Lange <[email protected]>
8
 * @copyright 2017
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
/** global: OC */
27
/** global: OCA */
28
/** global: Notyf */
29
30
/** global: actions */
31
/** global: nav */
32
/** global: elements */
33
/** global: resultMembers */
34
/** global: resultCircles */
35
/** global: curr */
36
/** global: api */
37
38
39
var actions = {
40
41
42
	changeMemberLevel: function (member, level) {
43
		api.levelMember(curr.circle, member, level, resultMembers.levelMemberResult);
44
		nav.circlesActionReturn();
45
	},
46
47
48
	changeMemberStatus: function (member, value) {
49
		if (value === 'remove_member' || value === 'dismiss_request') {
50
			api.removeMember(curr.circle, member, resultMembers.removeMemberResult);
51
		}
52
		if (value === 'accept_request') {
53
			api.addMember(curr.circle, member, resultMembers.addMemberResult);
54
		}
55
	},
56
57
58
	selectCircle: function (circle_id) {
59
		curr.searchUser = '';
60
		elements.addMember.val('');
61
		elements.linkCircle.val('');
62
63
		nav.circlesActionReturn();
64
		api.detailsCircle(circle_id, resultCircles.selectCircleResult);
65
	},
66
67
68
	unselectCircle: function (circle_id) {
69
		elements.mainUIMembersTable.emptyTable();
70
		elements.navigation.children(".circle[circle-id='" + circle_id + "']").remove();
71
		elements.emptyContent.show(800);
72
		elements.mainUI.fadeOut(800);
73
74
		curr.circle = 0;
75
		curr.circleLevel = 0;
76
	},
77
78
79
	saveSettings: function () {
80
		data = {
0 ignored issues
show
Bug introduced by
The variable data seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.data.
Loading history...
81
			allow_links: (elements.settingsLink.is(":checked")),
82
			allow_links_auto: (elements.settingsLinkAuto.is(":checked")),
83
			allow_links_files: (elements.settingsLinkFiles.is(":checked"))
84
		};
85
86
		api.settingsCircle(curr.circle, data, settings.saveSettingsResult);
0 ignored issues
show
Bug introduced by
The variable settings seems to be never declared. If this is a global, consider adding a /** global: settings */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
87
	},
88
89
	/**
90
	 *
91
	 * @param search
92
	 */
93
	searchMembersRequest: function (search) {
94
95
		if (curr.searchUser === search) {
96
			return;
97
		}
98
99
		curr.searchUser = search;
100
101
		$.get(OC.linkToOCS('apps/files_sharing/api/v1', 1) + 'sharees',
102
			{
103
				format: 'json',
104
				search: search,
105
				perPage: 200,
106
				itemType: 'principals'
107
			}, resultMembers.searchMembersResult);
108
	},
109
110
111
	getStringTypeFromType: function (type) {
112
		switch (type) {
0 ignored issues
show
Coding Style introduced by
As per coding-style, switch statements should have a default case.
Loading history...
113
			case '1':
114
				return t('circles', 'Personal circle');
115
			case '2':
116
				return t('circles', 'Hidden circle');
117
			case '4':
118
				return t('circles', 'Private circle');
119
			case '8':
120
				return t('circles', 'Public circle');
121
		}
122
123
		return t('circles', 'Circle');
124
	},
125
126
127
	/**
128
	 *
129
	 */
130
	onEventNewCircle: function () {
131
		curr.circle = 0;
132
		curr.circleLevel = 0;
133
134
		elements.circlesList.children('div').removeClass('selected');
135
		elements.emptyContent.show(800);
136
		elements.mainUI.fadeOut(800);
137
	},
138
139
140
	/**
141
	 *
142
	 */
143
	onEventNewCircleName: function () {
144
		this.onEventNewCircle();
145
		nav.displayOptionsNewCircle((elements.newName.val() !== ''));
146
	},
147
148
149
	/**
150
	 *
151
	 */
152
	onEventNewCircleType: function () {
153
		this.onEventNewCircle();
154
		elements.newTypeDefinition.children('div').fadeOut(300);
155
		var selectedType = elements.newType.children('option:selected').val();
156
		if (selectedType === '') {
157
			elements.newType.addClass('select_none');
158
		}
159
		else {
160
			elements.newType.removeClass('select_none');
161
			$('#circles_new_type_' + selectedType).fadeIn(
162
				300);
163
		}
164
	}
165
166
167
};
168